Skip to content

fix(ci): build the Rust fastled CLI from source when binstall fails - #66

Merged
zackees merged 1 commit into
mainfrom
fix/ci-build-rust-binary
May 13, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/ci-build-rust-binary

Conversation

@zackees

@zackees zackees commented May 13, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to PR #65, which merged the Python _find_rust_fastled_cli helper. The helper now correctly avoids the Python entry-point shim — but in CI the lookup returns None because the Rust binary is missing entirely:

  • cargo binstall fastled-cli fails (no published release yet).
  • cargo test --workspace (in ./test) compiles the test binary into target/<arch>/debug/deps/ but does not always produce the main bin output at target/<arch>/debug/fastled[.exe].
  • The Build Webpage / deploy job never runs cargo test at all.

Result: Api.project_init and download_cpp_devtools_extension fail across every runner with RuntimeError: Could not locate the fastled CLI binary (visible in the current red unit-test + deploy jobs on main).

Fix

When cargo binstall fastled-cli does not supply a pre-built copy, ./install now falls back to building the binary from source:

"$(dirname "$0")/_cargo" build --release --bin fastled
  • Uses the existing _cargo trampoline so the MSVC target gets forced on Windows (matching the directories _rust_cli.py searches).
  • Same single-source-of-truth applies to both unit-test and deploy jobs — they all go through ./install.
  • No-op for the case where cargo binstall succeeds (release published) — that path still wins.

Test plan

  • bash -n install clean
  • bash lint clean
  • bash test — 119 unit tests pass locally with the binary populated in target/debug/
  • CI green — call / unit-test and deploy jobs both turn green

Refs #63, #64, #65

🤖 Generated with Claude Code

PR #65 added a Python `_find_rust_fastled_cli` helper that locates the
Rust binary by walking `target/{release,debug}/`, `$CARGO_HOME/bin`, and
PATH (skipping Python venv dirs). On CI the helper now correctly skips
the Python entry-point shim — but then returns `None` because the Rust
binary is missing entirely:

* `cargo binstall fastled-cli` fails (no release published yet).
* `cargo test --workspace` (in `./test`) compiles the test binary into
  `target/<arch>/debug/deps/` but does not always produce the main bin
  output at `target/<arch>/debug/fastled[.exe]`.
* The Build Webpage / deploy job never runs `cargo test` at all.

So `Api.project_init` / `download_cpp_devtools_extension` fail with
"Could not locate the fastled CLI binary" on every CI runner.

Fix: when cargo-binstall does not supply a pre-built copy, fall back to
`cargo build --release --bin fastled` inside `./install`. Both the
unit-test and deploy jobs go through `./install`, so this covers both
broken paths. Uses the local `_cargo` trampoline so the MSVC target is
forced on Windows (matching where the existing helper searches).

Local: `bash lint` clean, 119 unit tests pass.
@zackees
zackees merged commit cd5a7bb into main May 13, 2026
23 of 25 checks passed
zackees added a commit that referenced this pull request May 13, 2026
PR #68's deploy job failed with `FileNotFoundError: fastled executable
not found` because `build_site.py` does `which("fastled")` and shells
out to plain `fastled --init=...`. Editable installs (`uv pip install -e
.`) don't extract the maturin `data` dir to the venv's Scripts/, so
PATH lookup found nothing.

After cargo-build (the binstall fallback added in PR #66), copy the Rust
binary into:

* `.venv/Scripts/fastled.exe` (Windows) or `.venv/bin/fastled` (Unix) —
  mimics the wheel-install layout so PATH lookup resolves to the Rust
  binary for editable installs.
* `wheel-data/scripts/fastled[.exe]` — so subsequent `./build-wheel`
  bundles the same binary into the wheel.

Discovery walks the candidate `target/<triple>/release/`,
`target/release/`, and `$CARGO_HOME/bin/` paths so both cargo-build and
cargo-binstall outputs are handled.
zackees added a commit that referenced this pull request May 13, 2026
* feat: bundle the Rust fastled CLI binary in the wheel (closes #67)

End users who `pip install fastled` will now receive the Rust `fastled`
binary directly in their venv's Scripts/bin directory — no Python
entry-point shim, no cargo build at install time.

Mechanism: maturin's `[tool.maturin] data` config points at a
`wheel-data/` directory which it packages as the wheel's
`<pkg>-<ver>.data/` tree. Pip extracts `data/scripts/*` to the venv's
Scripts/ (Windows) or bin/ (Unix) on install. Verified locally:

    $ ./build-wheel
    $ unzip -l target/wheels/fastled-2.0.7-cp310-abi3-win_amd64.whl | grep .data
        6303744  fastled-2.0.7.data/scripts/fastled.exe

    $ uv pip install target/wheels/fastled-*.whl
    $ which fastled
    /tmp/test-venv/Scripts/fastled.exe        # the Rust binary
    $ fastled --version
    fastled 2.0.7

Changes:

- `crates/fastled-cli/src/lib.rs` (new) — moved the body of main.rs and
  renamed `fn main` to `pub fn run`. `crates/fastled-cli/src/main.rs`
  shrinks to a one-liner calling `fastled_cli::run()`. The crate now
  exposes both `[lib]` and `[[bin]]`, so the binary's logic can also be
  called from other consumers in the future.
- `pyproject.toml` — adds `[tool.maturin] data = "wheel-data"`; drops
  `fastled = "fastled.cli:main"` from `[project.scripts]` (the Rust
  binary takes over that command). `fled` and `fastled-wasm` stay as
  Python aliases.
- `build-wheel` (new) — helper that compiles the bin via the `_cargo`
  trampoline, stages it under `wheel-data/scripts/`, then runs
  `maturin build --release`.
- `.github/workflows/_build.yml` — adds a pre-step that compiles the bin
  for the target triple and stages it under `wheel-data/scripts/` before
  the existing `maturin build` step. Cross-compile path handled.
- `src/fastled/_rust_cli.py` — drops the `_looks_like_python_dir` PATH
  filter; the Python `fastled` shim no longer exists, so plain
  `shutil.which("fastled")` is sufficient for the wheel-install case.
- `.gitignore` — ignore `wheel-data/`.

Editable installs (CI unit-test, deploy, local dev) are unchanged: the
existing cargo-build fallback in `./install` (PR #66) keeps populating
`target/release/fastled` for the workspace-target lookup. A follow-up
can switch CI's editable installs to wheel installs if desired, but
that's orthogonal to this PR.

Local: `bash lint` clean, 119 unit tests pass.

* fix(ci): create wheel-data/ before invoking maturin

PR #68's `[tool.maturin] data = "wheel-data"` config requires the
directory to exist at maturin invocation time. CI jobs (build,
unit-test, integration-test, deploy) all run `./install` which does
`uv pip install -e .` → maturin pep517 build-wheel; without wheel-data
present, maturin errors with `Caused by: No such data directory`.

Move the directory creation to the top of `./install`, before any
maturin invocation. The cargo-build step later in the same script
populates `wheel-data/scripts/` with the Rust binary for downstream
`./build-wheel` use; an empty dir is sufficient for the editable-install
path that pip drives.

* fix(ci): stage Rust fastled binary into the venv after cargo build

PR #68's deploy job failed with `FileNotFoundError: fastled executable
not found` because `build_site.py` does `which("fastled")` and shells
out to plain `fastled --init=...`. Editable installs (`uv pip install -e
.`) don't extract the maturin `data` dir to the venv's Scripts/, so
PATH lookup found nothing.

After cargo-build (the binstall fallback added in PR #66), copy the Rust
binary into:

* `.venv/Scripts/fastled.exe` (Windows) or `.venv/bin/fastled` (Unix) —
  mimics the wheel-install layout so PATH lookup resolves to the Rust
  binary for editable installs.
* `wheel-data/scripts/fastled[.exe]` — so subsequent `./build-wheel`
  bundles the same binary into the wheel.

Discovery walks the candidate `target/<triple>/release/`,
`target/release/`, and `$CARGO_HOME/bin/` paths so both cargo-build and
cargo-binstall outputs are handled.
zackees added a commit that referenced this pull request May 13, 2026
Sweeps the non-Python items issue #59 flagged that are still on main
after PRs #61, #62, #64, #65, #66, #68 cleaned up the Python side:

* `entrypoint.sh` — Docker container entrypoint. Sourced
  `/emsdk/emsdk_env.sh` (container path) and called
  `fastled_wasm_compiler.cli_update_from_master` (a module from a
  separate package that only exists inside the container).
* `compiler/run.py` — Docker compile-server entry point. Imports
  `fastled_wasm_compiler`, a separate package not in this repo.
* `compiler/debug.sh` — instructed user to run from `/js` (container
  working directory). Empty `compiler/` directory removed.
* `.dockerignore` — only contained cache exclusions
  (`**/.mypy_cache/`, `**/.ruff_cache/`) which belong in `.gitignore`
  if anywhere; no Docker build context this could serve.
* `chrome_vscode_bridge_design_task.md` — one-off design draft that
  opens with "Here's a refined ... file for your repo. Feel free to
  adjust...". Zero references anywhere else.
* `upload_package.sh` — manual PyPI upload helper, superseded by the
  automated `publish_release.yml` workflow. Zero inbound references.
* Empty root-level `fastled/` directory left over from a prior layout.

`lint` script updated to stop passing the (now-deleted) `compiler/` path
to ruff / black / isort / pyright / the keyboard-interrupt checker.

`bash lint` clean. `bash test` — 119 pass.

Verified by grep across `*.py`, `*.rs`, `*.toml`, `*.yml`, `*.sh`,
`*.md`, `Cargo.toml` (excluding `.venv/` and `.claude/worktrees/`):
none of the deleted files are referenced from a live code path or
workflow.
@zackees
zackees deleted the fix/ci-build-rust-binary branch November 5, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant